package com.soilflow.web.controller.reception.web;

import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.SysArticle;
import com.soilflow.common.domain.dto.SysArticleDto;
import com.soilflow.common.domain.vo.SysArticleVo;
import com.soilflow.common.domain.vo.categoryArticleVo;
import com.soilflow.common.domain.vo.categorySearchVo;
import com.soilflow.info.service.ISysArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/reception/article")
@RestController
public class ArticleController extends BaseController {
    @Autowired
    private ISysArticleService sysArticleService;

    /**
     * 显示热门文章
     * @return
     */
    @GetMapping("/hotArticleList")
    public TableDataInfo hotArticleList(){
        List<SysArticleVo> list = sysArticleService.hotArticleList();
        return getDataTable(list);
    }
    /**
     * 根据分类展示最新文章
     * @param id 分类id
     * @return
     */
    @GetMapping("/categoryList")
    public TableDataInfo categoryList(Long id){
        System.out.println("ids = " + id);
        List<categoryArticleVo> list = sysArticleService.categoryList(id);
        return getDataTable(list);
    }
    /**
     * 根据分类搜索文章；
     */
    @GetMapping("/categorySerach")
    public categorySearchVo categorySerach(String id){
        return sysArticleService.categorySerach(id);
    }
    /**
     * 查询文章，并查出该文章的点赞数据、收藏数据
     */
    @GetMapping("/selectarticle")
    public TableDataInfo selectarticle(SysArticleDto sysArticle){
        startPage();
        List<SysArticle> list = sysArticleService.selectarticle(sysArticle);
        return getDataTable(list);
    }

}
